package JodaTime;

import org.joda.time.Chronology;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.Days;
import org.joda.time.Instant;
import org.joda.time.LocalDate;
import org.joda.time.LocalTime;
import org.joda.time.Period;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

import java.util.Date;
import java.util.Locale;

/**
 * Created by wangyg 
 * on 2017/7/17 17:33
 */
public class mmm {
	/*public static void main(String[] args) {
		DateTime dateTime = new DateTime();
		int year = dateTime.getYear();
		System.out.println(year);
		DateTimeZone zone = dateTime.getZone();
		System.out.println(zone);
		Chronology chronology = dateTime.getChronology();
		System.out.println(chronology);

		DateTime dt = new DateTime();
		String monthName = dt.monthOfYear().getAsText();
		String frenchShortName = dt.monthOfYear().getAsShortText(Locale.JAPAN);
		boolean isLeapYear = dt.year().isLeap();
		DateTime rounded = dt.dayOfMonth().roundFloorCopy();
		Days days = daysToNewYear(new LocalDate());
		System.out.println(days.toString());
		System.out.println(days.getDays());
		DateTime dateTime = new DateTime().minusDays(2).minusHours(13);
		boolean rentalOverdue = isRentalOverdue(dateTime);
		System.out.println(rentalOverdue);
		Date date = dateTime.toDate();

		System.out.println(Instant.now());
		System.out.println(new Instant());
		System.out.println(LocalTime.now());
		System.out.println();

	}
	public static Days daysToNewYear(LocalDate fromDate) {
		LocalDate newYear = fromDate.plusYears(1).withDayOfYear(1);
		return Days.daysBetween(fromDate, newYear);
	}

	public static boolean isRentalOverdue(DateTime datetimeRented) {
		Period rentalPeriod = new Period().withDays(2).withHours(12);
		return datetimeRented.plus(rentalPeriod).isBeforeNow();
	}*/

	public static void main(String[] args) {
		DateTimeFormatter format = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
		DateTime dt = DateTime.parse("2017-07-01 12:01:01", format);
		DateTime dateTime = dt.plusMonths(1).plusDays(20).plusHours(11).plusMinutes(1);
		System.out.println(dateTime.toString("yyyy-MM-dd HH:mm:ss"));
		System.out.println(dateTime.toDate());
//		System.out.println(DateTime.now());
		System.out.println(new DateTime().toDate());
		System.out.println(new Date());
	}

}
